package com.crm.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.crm.domain.entity.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserManagementMapper extends BaseMapper<User> {

    @Select("select * from user where user_name = #{username}")
    User getUser(String username);

    @Select("SELECT * FROM user LIMIT #{offset}, #{pageSize}")
    List<User> selectUserByPage(@Param("offset") Integer offset, @Param("pageSize") Integer pageSize);

    @Select("SELECT COUNT(*) FROM user")
    Integer countUsers();

    @Select("select * from user where dept_id in (#{deptId})")
    List<User> selectByDeptIds(Integer deptId);


    @Select("select * from user where dept_id = #{deptid}")
    List<User> findUsersByDeptId(Long deptId);


    @Delete("delete from user where user_id = #{id}")
    void removeById(Long id);
}
